// pages/user/logistics/logistics.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    noImg: '../../../images/none.png',
    logisticsInfo:[],
    order_id:''
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    var order_id = options.order_id;
    that.setData({
      order_id: order_id
    })

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this;
    that.getOrderLogistics();

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },
  // 获取物流信息
  getOrderLogistics: function(){
    var that = this;
    var order_id = that.data.order_id;
    app.ajax({
      url: 'User/Order/orderLogistics',
      method:'POST',
      data:{
        order_id: order_id
      },
      success: function(res){
        if(res.data.code == 1000){
          var logisticsInfo = res.data.data;
          that.setData({
            logisticsInfo: logisticsInfo
          })
        }
      }
    })

  },
  // 复制订单号
  copyNumber: function(e){
    var that = this;
    var Number = e.currentTarget.dataset.number;
    wx.setClipboardData({
      data: Number,
      success: function (res) {
        wx.getClipboardData({
          success: function (res) {
            console.log(res.data) // data
          }
        })
      }
    })
  },
  // 拨打电话
  callPhone: function(e){
    var that = this;
    var phone = e.currentTarget.dataset.phone;
    wx.makePhoneCall({
      phoneNumber: phone,
    })
  },
})